var timerobj, timer, roleType, userId;
mui.init({
	pullRefresh: {
		container: '#pullrefresh',
		down: { //下拉刷新
			callback: pulldownRefresh,
			style: mui.os.android ? "circle" : "default"
		}
	}
});



mui.plusReady(function() {
	roleType = localStorage.getItem("roleType");
	userId = localStorage.getItem("userId");
	initPage();

	//	if(!storageLocation.Lon || storageLocation.Lon == "") { //未拿到定位信息
	//		plus.nativeUI.showWaiting("定位中...");
	//		plus.geolocation.getCurrentPosition(function(position) {
	//			plus.nativeUI.closeWaiting();
	//			storageLocation.refreshData(position);
	//			storageLocation.log();
	//			initPage();				
	//		}, function(e) {
	//			plus.nativeUI.closeWaiting();
	//			mui.alert(JSON.stringify(e));
	//			//appUI.showTopTip("定位失败，请手动选择位置"+JSON.stringify(e));
	//		}, {
	//			geocode: true
	//		});
	//	} else {
	//		initPage();
	//	}

	//点击进入任务
	mui("#list_wrap").on('tap', 'li', function() {
		var inspectUnitId = this.getAttribute("data-id");
		// openNew("checkReport.html", {
		// 	inspectUnitId: inspectUnitId
		// });
		openNew("bbsDetails.html", {
			inspectUnitId: inspectUnitId
		});
	})
})

function initPage() {
	loadData();
}
//下拉刷新具体业务实现
function pulldownRefresh() {
	loadData();
}
//一次性拉取数据
function loadData() {
	request("/app/alarm/select/plan/list", "GET",{
		id: userId
		// ,
		// roleType: roleType,
		// pageNum: 1,
		// pageSize: 20
	}, function(res) {
		plus.nativeUI.closeWaiting();
		//console.log(JSON.stringify(res))
		if (res.pager.total <= 0){
			document.getElementById('noData').style.display = 'block';
		} else {
			document.getElementById('noData').style.display = 'none';
			render('#list_wrap', 'inspectUnitList', res)
			appPage.endPullRefresh();
		}
		
	}, true, function() {
		appPage.endPullRefresh();
		
	});
}
